package com._520it.wms.web.controller;

import com._520it.wms.query.QueryObject;
import com._520it.wms.service.IPermissionService;
import com._520it.wms.util.JSONResult;
import com._520it.wms.util.RequiredPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by HASEE on 2017/11/14.
 */
@Controller
@RequestMapping("/permission")
public class PermissionContorller {
    @Autowired
    private IPermissionService permissionService;

    @RequestMapping("/list")
    @RequiredPermission("权限列表")
    public String list(Model model, QueryObject qo) {
        model.addAttribute("pageResult", permissionService.query(qo));
        return "/permission/list";
    }

    @RequestMapping("delete")
    @ResponseBody
    @RequiredPermission("权限删除")
    public JSONResult delete(Long id) {
        if (id != null) {
            permissionService.delete(id);
        }
        return new JSONResult();
    }

    @RequestMapping("/reload")
    @ResponseBody
    @RequiredPermission("权限加载")
    public JSONResult reload() {//加载权限
        permissionService.reload();
        return new JSONResult();
    }
}
